package com.z8888q.zstopwatch.rewrite;

import android.os.Handler;
import android.os.Message;

import com.z8888q.zstopwatch.ZstopwatchX;

public class RewriteHandler extends Handler {
	private ZstopwatchX zsw;
	int directionX = 1, directionY = 1;

	public RewriteHandler(ZstopwatchX zsw) {
		this.zsw = zsw;
	}

	@Override
	public void handleMessage(Message msg) {

		zsw.text_show_h.setText(getString(zsw.time_h));
		zsw.text_show_m.setText(getString(zsw.time_m));
		zsw.text_show_s.setText(getString(zsw.time_s));
		zsw.text_show_ms.setText(getString(zsw.time_ms));

		// circle cut
		if (((zsw.record_page - 1) * 9 + zsw.littleButtonSelect) == zsw.cut_select) {
			String tempString = getString(zsw.circle_time_h) + ":"
					+ getString(zsw.circle_time_m) + ":"
					+ getString(zsw.circle_time_s) + ":"
					+ getString(zsw.circle_time_ms);
			zsw.buttonCircle.setText(tempString);
		}
	}

	private String getString(int i) {
		if (i < 10) {
			return "0" + i;
		} else {
			return "" + i;
		}
	}
}
